#include<bits/stdc++.h>
#define int long long 
#define endl "\n"
#define IOS ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)

using namespace std;

signed main() {
	IOS;
	int n;
	cin >> n;
	int a[n + 10];
	int z[n + 10];
	int sum[n + 10];
	sum[0] = 0;
	z[0] = 0;
	for(int i = 1; i <= n; i ++ ) {
		cin >> a[i];
		z[i] = z[i - 1];
		if(a[i] > 0) {
			z[i] ++ ;
		}
		sum[i] = sum[i - 1] + a[i];
	}
	int ret = 0;
	for(int i = 1; i <= n - 2; i ++ ) {
		if(sum[i] * 3 == sum[n])
		for(int j = i + 1; j <= n - 1; j ++ ) {
			if(z[j] == z[n]) {
				break;
			}
			if(sum[i] == sum[j] - sum[i] && sum[i] == sum[n] - sum[j] && z[i] && z[j] - z[i] && z[n] - z[j]) {
				ret ++ ;
			}
		}
	}
	
	cout << ret << endl;
	return 0;
}

